#include <bits/stdc++.h>
using namespace std;
long long n, m, l, vl;
long long d[200000], a[200000], v[200000];
long long p[200000];
int s[2000000];//
int ok[200000];
struct node {
	long l;
	long r;
} qu[200000];
node qu2[200000];
bool cmp(node a, node b) {
	if (a.l == b.l) return a.r >= b.r;
	return a.l < b.l;
}
int main() {
	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);
	int t;
	cin >> t;
	while(t--) {
		cin >> n >> m >> l >> vl;
		for (int i = 0; i < 200000; i++) {
			d[i] = a[i] = v[i] = p[i] = ok[i] = 0;
		}
		for (int i = 0; i < 2000000; i++) {
			s[i] = 0;
		}
		for (int i = 0; i < n; i++) {
			cin >> d[i] >> v[i] >> a[i];
		}
		for (int i = 0; i < m; i++) {
			cin >> p[i];
		}
		s[0] = 0;
		int temp = 0;
		for (int i = 1; i <= l + 1; i++) {
			if  (p[temp] == i - 1) {
				temp++;
				s[i]++;
			}
			s[i] += s[i - 1];
		}
		int tot = 0;
		int num = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] == 0) {
				if (v[i] > vl) {
					qu[num].l = d[i];
					qu[num].r = l;
					num++;
				} else if (v[i] <= vl) {
					continue;
				}
			}
			if (a[i] > 0) {
				if (v[i] > vl) {
					qu[num].l = d[i];
					qu[num].r = l;
					num++;
				} else if (v[i] <= vl) {
					long long dis = (vl * vl - v[i] * v[i]) / (2 * a[i]);
					if (d[i] + dis >= l) continue;
					else {
							qu[num].l = d[i] + dis + 1;
							qu[num].r = l;
							num++;
					}
				}
			}
			if (a[i] < 0) {
				if (v[i] <= vl) {
					continue;
				} else if (v[i] > vl) {
					long long dis = (v[i] * v[i] - vl * vl - 1) / (-2 * a[i]);
					qu[num].l = d[i];
					qu[num].r = min(l, d[i] + dis);
					num++;
				}
			}
		}
		
		// to deal with the relationships between qu and detecter.
		// first question
		for (int i = 0; i < num; i++) {
			if (s[qu[i].r + 1] - s[qu[i].l] > 0) {
				tot++;
			}
		}
		/*
		for (int i = 0; i < num; i++) {
			cout << qu[i].l << " " << qu[i].r << endl;
		}
		*/
		cout << tot << " ";
		// done 1
		
		// second quest
		
		int tn = 0;
		sort(qu, qu + num, cmp);
		/*
		cout << endl << endl << endl;
		for (int i =0 ;i < num; i++) {
			cout << qu[i].l << " " << qu[i].r << endl;
		}
		cout << endl << endl << endl;
		*/
		for (int i = 0; i < num; i++) {
			bool flag = 0;
			for (int j = i + 1; j < num; j++) {
				if (qu[j].l > qu[i].r) break;
				if (qu[j].r <= qu[i].r) {
					flag = 1;
					break;
				}
			}
			if (flag == 0) {
				qu2[tn].l = qu[i].l;
				qu2[tn].r = qu[i].r;
				tn++;
			}
		}
		
		int ans = 0;
		for (int i = 0; i < tn; i++) {
			if (ok[i]) {
				continue;
			}
			ans += 1;
			for (int j = i + 1; j < tn; j++) {
				if (qu2[j].l > qu2[i].r) break;
				if (s[qu2[i].r + 1] - s[qu2[j].l] > 0) ok[j] = 1;
			}
		}
		/*
		cout << endl << endl;
		cout << tn << endl;
		for (int i = 0; i < tn; i++) {
			cout << qu2[i].l << " " << qu2[i].r << "||" << ok[i] << endl;
		}
		cout << endl;
		*/
		
		cout << s[l + 1] - ans << endl;
		
	}
}
